package lanou3g.myfirstapp36kr.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

//import it.sephiroth.android.library.picasso.Picasso;
import com.squareup.picasso.Picasso;

import lanou3g.myfirstapp36kr.R;
import lanou3g.myfirstapp36kr.entity.ActivityLookforMoneyEntity;

/**
 * Created by dllo on 16/8/7.
 */
public class ActivityFindLookforMoneyLVAdapter extends BaseAdapter {
    private Context context;
    private ActivityLookforMoneyEntity entity;

    public ActivityFindLookforMoneyLVAdapter(Context context) {
        this.context = context;
    }

    public void setEntity(ActivityLookforMoneyEntity entity) {
        this.entity = entity;
    }

    @Override
    public int getCount() {
        return entity.getData().getData().size();
    }

    @Override
    public Object getItem(int i) {
        return entity.getData().getData().get(i);
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder viewHolder = null;
        if (view == null){
            view = LayoutInflater.from(context).inflate(R.layout.item_fragmentfind_lookfor_money_lv,null);
            viewHolder = new ViewHolder(view);
            view.setTag(viewHolder);
        }else {
            viewHolder = (ViewHolder) view.getTag();
        }
        Picasso.with(context).load(entity.getData().getData().get(i).getUser().getAvatar()).into(viewHolder.imageViewPic);
        viewHolder.textViewName.setText(entity.getData().getData().get(i).getUser().getName());
        for (int j = 0; j < entity.getData().getData().get(i).getFocusIndustry().size(); j++) {
            if (j == 0){

                viewHolder.textViewField.setText(entity.getData().getData().get(i).getFocusIndustry().get(j));
            }else {
                //viewHolder.textViewField.setText("未批露");
            }
            if (j == 1){
                viewHolder.textViewField2.setText(entity.getData().getData().get(i).getFocusIndustry().get(j));
            }
            if (j == 2){
                viewHolder.textViewField3.setText(entity.getData().getData().get(i).getFocusIndustry().get(j));
            }
        }
        for (int j = 0; j < entity.getData().getData().get(i).getInvestPhases().size(); j++) {
            if (j == 0){

                viewHolder.textViewStage.setText(entity.getData().getData().get(i).getInvestPhases().get(j));
            }else {
                //viewHolder.textViewField.setText("未批露");
            }
            if (j == 1){
                viewHolder.textViewStage2.setText(entity.getData().getData().get(i).getInvestPhases().get(j));
            }
            if (j == 2){
                viewHolder.textViewStage3.setText(entity.getData().getData().get(i).getInvestPhases().get(j));
            }
        }
        return view;
    }
    private class ViewHolder {
        private ImageView imageViewPic;
        private TextView textViewName;
        private TextView textViewField;
        private TextView textViewField2;
        private TextView textViewField3;
        private TextView textViewStage;
        private TextView textViewStage2;
        private TextView textViewStage3;
        public ViewHolder(View view) {
            imageViewPic = (ImageView) view.findViewById(R.id.iv_picture);
            textViewName = (TextView) view.findViewById(R.id.tv_name);
            textViewField = (TextView) view.findViewById(R.id.tv_field1);
            textViewField2 = (TextView) view.findViewById(R.id.tv_field2);
            textViewField3 = (TextView) view.findViewById(R.id.tv_field3);
            textViewStage = (TextView) view.findViewById(R.id.stage1);
            textViewStage2 = (TextView) view.findViewById(R.id.stage2);
            textViewStage3 = (TextView) view.findViewById(R.id.stage3);

        }
    }
}
